//
//  WDPDIntroCell.m
//  Zhihuijinfu
//
//  Created by 王笛 on 2016/12/27.
//  Copyright © 2016年 王笛. All rights reserved.
//

#import "WDPDIntroCell.h"
#import "WDPDBottom.h"
#import "WDPDLeftBottom.h"

@interface WDPDIntroCell ()
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *leftLabel;
@property (weak, nonatomic) IBOutlet UILabel *valueLabel;
@property (weak, nonatomic) IBOutlet UIImageView *remarkView;

@end

@implementation WDPDIntroCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    //图片自适应
    self.iconView.contentMode = UIViewContentModeScaleAspectFit;
    
}

+ (instancetype)introCellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"introCell";
    
    WDPDIntroCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    if (!cell) {
        cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
    }
    return cell;
}

- (void)setBottom:(WDPDBottom *)bottom
{
    _bottom = bottom;
    
    self.valueLabel.text = bottom.value;
    
    if ([bottom.remark isEqualToString:@""]) {
        self.remarkView.hidden = YES;
    } else {
        self.remarkView.hidden = NO;
    }
    
    [self layoutIfNeeded];
    
    bottom.cellHeight = CGRectGetMaxY(self.valueLabel.frame) + 11;
}

- (void)setLeftBottom:(WDPDLeftBottom *)leftBottom
{
    _leftBottom = leftBottom;
    
    self.iconView.image = [UIImage imageNamed:leftBottom.icon];
    
    self.leftLabel.text = leftBottom.intro;
}

@end
